package com.genesis.mall.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private Integer code;
    private String message;
    private T data;

    /**
     * 成功
     * @param data
     * @param <T>
     * @return
     */
    public static  <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.code=200;
        result.data = data;

        return result;
    }

    public static  <T> Result<T> error(String msg) {
        Result<T> result = new Result<>();
        result.code=0;
        result.message = msg;
        return result;
    }

    public static  <T> Result<T> success() {
        Result<T> result = new Result<>();
        result.code=200;
        return result;
    }

    public static  <T> Result<T> success(T data,String msg) {
        Result<T> result = new Result<>();
        result.code=200;
        result.data = data;
        result.message = msg;
        return result;
    }

}
